export default {
    methods: {
        getApproval(id, codes) {
            return new Promise(resolve => {
                this.axios({
                    method: 'get',
                    url: '/dms/capex/findSignById',
                    params: {id, progressCode: codes.join(',')}
                }).then(res => {
                    if (res.code === 200) {
                        if (Array.isArray(codes)) {
                            // let list = [];
                            // list = res.data.filter(item=>{
                            //     return codes.includes(item.progressCode)
                            // })
                            resolve(res.data)
                        } else {
                            resolve(res.data)
                        }

                    } else {
                        this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
                    }
                })
            })
        },
        getCurrentUser(list, code) {
            if (!(Array.isArray(list) && list.length > 0)) return {signPath:"",createTime:""}
            const obj = list.find(item => item.flowProgressCode === code)
            if (!obj) return {signPath:"",createTime:""}
            obj.signPath = this.util.filePathToUrl(obj.signPath)
            obj.createTime = this.$moment(obj.createTime).format('YYYY-MM-DD')
            return obj
        },
        getApprovalUserInfo(list, progressCode){
            const obj = list.find(item => item.progressCode === progressCode) || {createTime:""}
            return obj
        },
        getCurrentApproval(list, code) {
            if (!(Array.isArray(list) && list.length > 0)) return {}
            return list.find(item => item.progressCode == code) || {}
        },
    }
}
